package com.ruoyi.lab.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.lab.annotation.SeatOperate;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.lab.domain.LabAppointMessage;
import com.ruoyi.lab.service.ILabAppointMessageService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 学生预约信息Controller
 * 
 * @author dn
 * @date 2023-12-31
 */
@RestController
@RequestMapping("/lab/appoint")
public class LabAppointMessageController extends BaseController
{
    @Autowired
    private ILabAppointMessageService labAppointMessageService;

    /**
     * 查询学生预约信息列表
     */
    @PreAuthorize("@ss.hasPermi('lab:appoint:list')")
    @GetMapping("/list")
    public TableDataInfo list(LabAppointMessage labAppointMessage)
    {
        startPage();
        List<LabAppointMessage> list = labAppointMessageService.selectLabAppointMessageList(labAppointMessage);
        return getDataTable(list);
    }

    /**
     * 导出学生预约信息列表
     */
    @PreAuthorize("@ss.hasPermi('lab:appoint:export')")
    @Log(title = "学生预约信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LabAppointMessage labAppointMessage)
    {
        List<LabAppointMessage> list = labAppointMessageService.selectLabAppointMessageList(labAppointMessage);
        ExcelUtil<LabAppointMessage> util = new ExcelUtil<LabAppointMessage>(LabAppointMessage.class);
        util.exportExcel(response, list, "学生预约信息数据");
    }

    /**
     * 获取学生预约信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('lab:appoint:query')")
    @GetMapping(value = "/{appointId}")
    public AjaxResult getInfo(@PathVariable("appointId") Long appointId)
    {
        return success(labAppointMessageService.selectLabAppointMessageByAppointId(appointId));
    }

    /**
     * 新增学生预约信息
     */
    @PreAuthorize("@ss.hasPermi('lab:appoint:add')")
    @Log(title = "学生预约信息", businessType = BusinessType.INSERT)
    @PostMapping
    @SeatOperate
    public AjaxResult add(@RequestBody LabAppointMessage labAppointMessage)
    {
        return toAjax(labAppointMessageService.insertLabAppointMessage(labAppointMessage));
    }

    /**
     * 修改学生预约信息
     */
    @PreAuthorize("@ss.hasPermi('lab:appoint:edit')")
    @Log(title = "学生预约信息", businessType = BusinessType.UPDATE)
    @PutMapping
    @SeatOperate
    public AjaxResult edit(@RequestBody LabAppointMessage labAppointMessage)
    {
        return toAjax(labAppointMessageService.updateLabAppointMessage(labAppointMessage));
    }

    /**
     * 删除学生预约信息
     */
    @PreAuthorize("@ss.hasPermi('lab:appoint:remove')")
    @Log(title = "学生预约信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{appointIds}")
    @SeatOperate
    public AjaxResult remove(@PathVariable Long[] appointIds)
    {
        return toAjax(labAppointMessageService.deleteLabAppointMessageByAppointIds(appointIds));
    }
}
